<!DOCTYPE html>
<html lang="en">
<!-- 修改登录密码页面 -->
<?php
// 判断是否正常访问
session_start();
if (!isset($_SESSION['USER'])) {
    echo "<script>alert('非法访问！请先登录！');window.location.href='../../../index.html';</script>";
    die();
}
?>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>校园报修系统 · 用户</title>
    <link rel="icon" href="../img/ICO.png">
    <link rel="stylesheet" href="../bootstrap-5.3.3-dist/bootstrap.min.css">
    <link rel="stylesheet" href="css/all.min.css">
    <script src="../bootstrap-5.3.3-dist/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/u-public.css">
    <link rel="stylesheet" href="css/u-change-password.css">
    <script src="js/change-info.js"></script>
</head>

<body>
    <header class="sticky-top">
        <nav class="navbar navbar-expand-lg bg-body-tertiary bg-dark border-body" data-bs-theme="dark">
            <div class="container-fluid">
                <a class="navbar-brand" href="u-main.php">
                    <img src="../img/logo-0.png" alt="Logo" height="50" class="d-inline-block align-text-top">
                </a>
                <div class="collapse navbar-collapse" id="navbarNav">
                    <i class="fas fa-map-marker-alt" style="color: white;"> 位置：</i>
                    <ul class="navbar-nav">
                        <li class="nav-item">
                            <a class="nav-link active" aria-current="page" href="u-main.php">首页 &gt;</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link active" aria-current="page" href="javascript:;">密码修改</a>
                        </li>
                    </ul>
                </div>
                <span class="navbar-text navbar-text-control">
                    <i class="fa fa-user-friends" style="color: white; font-size: 25px"></i>
                    当前登录：<?php echo $_SESSION['USER']["u_name"]; ?>
                </span>
                <a class="navbar-brand" href="php/logout.php">
                    <i class="far fa-arrow-alt-circle-left" style="color: white; font-size: 25px" title="退出登录"></i>
                </a>
            </div>
        </nav>
    </header>
    <main>
        <div class="main-div">
            <div class="main-div-changepwd">
                <div class="main-div-changepwd-title">
                    <h2><i class="fas fa-key" style="font-size: 30px;"></i> 密码修改</h2>
                    <span class="changepwd-tips">你可以在此更改你的登录密码，这个操作需要验证你的原始密码，<b>密码长度要求在8-20位之间</b></span>
                    <hr>
                </div>
                <div class="main-div-changepwd-content">
                    <form class="row g-3 changepwd-form" method="post" action="php/change-info.php">
                        <input type="hidden" value="password" name="action">
                        <input type="hidden" name="u_id" value="<?php echo $_SESSION['USER']["u_id"]; ?>">
                        <div class="col-12">
                            <label for="old_pwd" class="form-label">原始密码</label>
                            <input type="password" class="form-control" id="old_pwd" name="old_pwd" required>
                        </div>
                        <div class="col-12">
                            <label for="new_pwd" class="form-label">新的密码</label>
                            <input type="password" class="form-control" id="new_pwd" name="new_pwd" required>
                        </div>
                        <div class="col-12">
                            <label for="renew_pwd" class="form-label">确认密码</label>
                            <input type="password" class="form-control" id="renew_pwd" name="renew_pwd" required>
                        </div>
                        <div class="col-12 changepwd-btn">
                            <button type="submit" class="btn btn-outline-primary btn-sub"  onclick="return changePassword()">提交修改</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </main>
    <footer class="fixed-bottom">
        校园报修系统© 2025®
    </footer>
</body>

</html>